package com.dsh.subscribeSetting.service.impl;

import com.dsh.subscribeSetting.dao.ConsultationAppointmentDao;
import com.dsh.subscribeSetting.entity.ConsultationAppointment;
import com.dsh.subscribeSetting.entity.TreatmentAppointment;
import com.dsh.subscribeSetting.service.ConsultationAppointmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 咨询列表(ConsultationAppointment)表服务实现类
 *
 * @author makejava
 * @since 2022-05-12 10:05:13
 */
@Service("consultationAppointmentService")
public class ConsultationAppointmentServiceImpl implements ConsultationAppointmentService {
    @Resource
    private ConsultationAppointmentDao consultationAppointmentDao;

    /**
     * 通过ID查询单条数据
     *
     * @return 实例对象
     */
    @Override
    public ConsultationAppointment queryById() {
        ConsultationAppointment consultationAppointment = consultationAppointmentDao.queryById();
        return consultationAppointment;
    }

    @Override
    public TreatmentAppointment selectOne() {
        TreatmentAppointment treatmentAppointment = consultationAppointmentDao.selectOne();
        return treatmentAppointment;
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ConsultationAppointment> queryAllByLimit(int offset, int limit) {
        return this.consultationAppointmentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param consultationAppointment 实例对象
     * @return 实例对象
     */
    @Override
    public ConsultationAppointment insert(ConsultationAppointment consultationAppointment) {
        this.consultationAppointmentDao.insert(consultationAppointment);
        return consultationAppointment;
    }

    /**
     * 修改数据
     *
     * @param consultationAppointment 实例对象
     * @return 实例对象
     */
    @Override
    public ConsultationAppointment update(ConsultationAppointment consultationAppointment) {
        this.consultationAppointmentDao.update(consultationAppointment);
        return this.queryById();
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.consultationAppointmentDao.deleteById(id) > 0;
    }
}